package com.xw.Utils;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * 获取Spring管理的bean的工具类
 * @author yangjianquan
 */
@Component
public class SpringBeanUtil implements ApplicationContextAware{
	private static ApplicationContext context;

	@Override
	public void setApplicationContext(ApplicationContext ctx) throws BeansException {
		SpringBeanUtil.context = ctx;
	}
	
	/** 
     * 获取对象 
     * @param name 
     * @return Object
     */  
    public static Object getBean(String name){  
        return context.getBean(name);  
    }  
	
	
}
